define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'steward/index' + location.search,
                    add_url: 'steward/add',
                    edit_url: 'steward/edit',
                    del_url: 'steward/del',
                    multi_url: 'steward/multi',
                    import_url: 'steward/import',
                    table: 'steward',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                searchFormVisible: true,// 默认显示搜索条件
                search: false,// 搜索框
                // commonSearch: false,// 搜索按钮
                showToggle: false,// 切换视图
                showColumns: false,// 显示列
                showExport: false,// 导出按钮
                columns: [
                    [
                        {checkbox: true},
                        {field: 'user.nickname', title: __('申请用户'), operate: false},
                        {field: 'type', title: __('类型'), searchList: {"1":__('小学'),"2":__('初中'),"3":__('高中'),"4":__('资深')}, formatter: Table.api.formatter.normal},
                        {field: 'avatar', title: __('Avatar'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'realname', title: __('Realname'), operate: 'LIKE'},
                        {field: 'gender', title: __('性别'), searchList: {"1":__('女'),"0":__('男')}, formatter: Table.api.formatter.normal},
                        {field: 'idcard_number', title: __('Idcard_number'), operate: 'LIKE'},
                        {field: 'idcard_a', title: __('身份证人像'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'idcard_b', title: __('Idcard_b'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'age', title: __('Age'), operate: false},
                        {field: 'forte', title: __('Forte'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'brief', title: __('Brief'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'honor', title: __('荣誉证书'), operate: false, events: Table.api.events.images, formatter: Table.api.formatter.images},
                        {field: 'certificate', title: __('资格证书'), operate: false, events: Table.api.events.images, formatter: Table.api.formatter.images},
                        {field: 'not_crime', title: __('Not_crime'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'status', title: __('Status'), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
